#include <bits/stdc++.h>
#define ll long long 
#define PI pair<int,int>
using namespace std;
struct node
{
	int d,v,a;
}cars[100005];
int cs[100005];
bool book[105][105];
bool test[1005];
int main()
{
	/**/freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);/**/
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int T;
	cin>>T;
	while(T--)
	{
		int n,m,L,V;
		int ans=0;
		cin>>n>>m>>L>>V;
		int flagg=1;
		for(int i=1;i<=n;i++)
		{
			cin>>cars[i].d>>cars[i].v>>cars[i].a;
			if(cars[i].a!=0)flagg=0;
		}
		for(int i=1;i<=m;i++)cin>>cs[i];
		if(flagg)
		{
			for(int i=1;i<=n;i++)
			if(cars[i].v>V&&cars[i].d<=cs[m])ans++;
			cout<<ans<<' ';
			if(ans)cout<<m-1<<"\n";
			else cout<<m<<"\n";
			continue;
		}
		for(int i=1;i<=n;i++)
		if(cs[m]>=cars[i].d&&1LL*(cs[m]-cars[i].d)*cars[i].a*2+1LL*cars[i].v*cars[i].v>V*V)
		ans++;
		cout<<ans<<' ';
		if(ans)cout<<m-1<<"\n";
		else cout<<m<<"\n";
	}
	return 0;
}
/**







/**/
